<template>
  <div class="PhotoArchival overflowY"  v-loading="loading">
    <!--<div class="PageTitle"><i class="iconfont icon-jia"></i>服务洽谈</div>-->
    <div class="PageContent ">
      <el-form :model="ruleForm" :inline="true" label-width="120px" class="demo-ruleForm" @submit.native.prevent>
        <div class="PageItem margintop20">
          <el-row :gutter="0" class="paddingleft2">
            <!--<el-form-item  label="业务编码:">-->
              <!--<el-input v-model="businessCode"  @keyup.enter.native="searchData" :maxlength="20"></el-input>-->
            <!--</el-form-item>-->
            <!--<el-button type="primary" v-if="btnRight.btnPhotoArchivalCodeScanning"  @click="searchData">扫描</el-button>-->
            <el-form-item  label="业务编码:" >
              <el-input v-model="businessCode" ref="photobusinessCode" @keyup.enter.native="searchData()" :maxlength="20">
                <el-button type="primary" slot="append" icon="el-icon-search" v-if="btnRight.btnPrintReplaceCodeScanning" @click="searchData(businessCode)"></el-button>
              </el-input>
            </el-form-item>
            <el-form-item label="逝者姓名:">
              <span class="titlecont">{{ruleForm.funeralDead.deadName}}</span>
            </el-form-item>
            <el-form-item label="减免区域:">
              <span class="titlecont">{{ ruleForm.funeralDead.benefitDistrict }}</span>
            </el-form-item>
            <el-form-item label="减免类型:">
              <span class="titlecont">{{ruleForm.funeralDead.exemptionType}}</span>
            </el-form-item>
            <el-form-item label="家属姓名:" >
              <span class="titlecont">{{ruleForm.familyMember.memberName}}</span>
            </el-form-item>
            <i class="el-icon-arrow-down more" v-if="!moreFlag" @click="moreFlag=!moreFlag">&nbsp;展开</i>
            <i class="el-icon-arrow-up more" v-if="moreFlag" @click="moreFlag=!moreFlag">&nbsp;收起</i>
          </el-row>
        </div>
        <div class="PageItem" v-if="moreFlag">
          <div style="display: inline-block;">
            <el-row class="PageInfo"><i class="info-bar"></i>逝者基本信息</el-row>
            <el-row :gutter="0" class="paddingleft2">
              <el-form-item label="业务编码:">
                <span class="cont">{{ruleForm.funeralDead.businessCode}}</span>
              </el-form-item>
              <el-form-item label="逝者姓名:">
                <span class="cont">{{ruleForm.funeralDead.deadName}}</span>
              </el-form-item>
              <el-form-item label="证件号码:">
                <span class="cont">{{ruleForm.funeralDead.certificateNo}}</span>
              </el-form-item>
              <el-form-item label="性别:">
                <span class="cont">{{ruleForm.funeralDead.deadGender}}</span>
              </el-form-item>
            </el-row>
            <el-row :gutter="0" class="paddingleft2">
              <el-form-item label="减免区域:">
                <span class="cont">{{ ruleForm.funeralDead.benefitDistrict }}</span>
              </el-form-item>
              <el-form-item label="减免类型:">
                <span class="cont">{{ruleForm.funeralDead.exemptionType}}</span>
              </el-form-item>
              <el-form-item label="接尸地点:">
                <span class="cont">{{ruleForm.funeralDead.transportPlace}}</span>
              </el-form-item>
            </el-row>
            <el-row class="PageInfo"><i class="info-bar"></i>家属基本信息</el-row>
            <el-row :gutter="0" class="paddingleft2">
              <el-form-item label="家属姓名:">
                <span class="cont">{{ruleForm.familyMember.memberName}}</span>
              </el-form-item>
              <el-form-item label="性别:">
                <span class="cont">{{ruleForm.familyMember.memberGenderCode}}</span>
              </el-form-item>
              <el-form-item label="手机号码:">
                <span class="cont">{{ruleForm.familyMember.mobilePhone}}</span>
              </el-form-item>
              <el-form-item label="联系电话:" >
                <span class="cont">{{ruleForm.familyMember.otherPhone}}</span>
              </el-form-item>
            </el-row>
            <el-row :gutter="0" class="paddingleft2">
              <el-form-item label="证件号码:">
                <span class="cont">{{ruleForm.familyMember.certificateNo}}</span>
              </el-form-item>
              <el-form-item label="与逝者关系:">
                <span class="cont">{{ruleForm.familyMember.memberRelation}}</span>
              </el-form-item>
              <el-form-item label="联系地址:">
                <span class="cont">{{ruleForm.familyMember.address}}</span>
              </el-form-item>
            </el-row>
            <el-row class="PageInfo"><i class="info-bar"></i>承办人基本信息</el-row>
            <el-row :gutter="0" class="paddingleft2">
              <el-form-item label="承办人类型:" >
                <span class="cont" v-if="ruleForm.familyAgent.agentType == 0">个人</span>
                <span class="cont" v-else-if="ruleForm.familyAgent.agentType == 1">单位</span>
                <span class="cont" v-else></span>
              </el-form-item>
              <el-form-item label="承办人单位/姓名:" >
                <span class="cont" v-if="ruleForm.familyAgent.agentType == 0">{{ruleForm.familyAgent.agentName}}</span>
                <span class="cont" v-else-if="ruleForm.familyAgent.agentType == 1">{{ruleForm.familyAgent.agentUnitName}}</span>
                <span class="cont" v-else></span>
              </el-form-item>
              <el-form-item label="手机号码:" >
                <span class="cont">{{ruleForm.familyAgent.mobilePhone}}</span>
              </el-form-item>
              <el-form-item label="联系电话:" >
                <span class="cont">{{ruleForm.familyAgent.otherPhone}}</span>
              </el-form-item>
            </el-row>
            <el-row :gutter="0" class="paddingleft2">
              <el-form-item label="证件号码:" >
                <span class="cont">{{ruleForm.familyAgent.certificateNo}}</span>
              </el-form-item>
              <el-form-item label="与逝者关系:" >
                <span class="cont">{{ruleForm.familyAgent.agentRelation}}</span>
              </el-form-item>
            </el-row>
          </div>
          <div class="avatar">
            <img width="100" src="../../../static/images/avatar.png"/>
          </div>
        </div>
      </el-form>
      <hr>
      <el-form :model="savePhoto" :inline="true"  :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
        <div class="PageItem">
          <el-row class="PageInfo"><i class="info-bar"></i>拍照备案</el-row>
          <div class="video">
            <div class="content">
              <object id="view1" type="application/x-eloamplugin" width="600" height="300" name="view"></object>
            </div>
            <div class="content">
              <object id="view2" type="application/x-eloamplugin" width="600" height="300" name="view"></object>
            </div>
          </div>
          <el-row :gutter="0"  class="paddingleft2">
            <el-form-item label="照片类型:" rop="name">
              <el-select  v-model="savePhoto.documentTypeCode" clearable filterable   placeholder="请选择处理方式" class="w150">
                <el-option
                  v-for="item in dictionary.document_type"
                  :key="item.dataCode"
                  :label="item.dataText"
                  :value="item.dataCode"
                  :disabled="item.disableState"/>
              </el-select>
            </el-form-item>
            <el-form-item label="设备1:" >
              <el-select  v-model="device.mainDeviceSelected" onkeydown="return (event.keyCode!=8)" @change="mainDeviceChange">
                <el-option  v-for="item in device.mainDevice" :key="item.device"
                            :label="item.text"
                            :value="item.value" />
              </el-select>
            </el-form-item>
            <el-form-item  >
              <el-select v-model="device.mainDeviceResolutionSelected" placeholder="请选择" @change="changeSubType(1)">
                <el-option  v-for="item in device.mainDeviceResolutions" :key="item.device"
                            :label="item.text"
                            :value="item.value" />
              </el-select>
            </el-form-item>
            <el-form-item label="设备2:" >
              <el-select  v-model="device.assistDeviceSelected"  @change="assistDeviceChange">
                <el-option  v-for="item in device.assistDevice" :key="item.device"
                            :label="item.text"
                            :value="item.value" />
              </el-select>
            </el-form-item>
            <el-form-item  >
              <el-select v-model="device.assistDeviceResolutionSelected" onkeydown="return (event.keyCode!=8)" placeholder="请选择" @change="changeSubType(2)">
                <el-option  v-for="item in device.assistDeviceResolutions" :key="item.device"
                            :label="item.text"
                            :value="item.value" />
              </el-select>
            </el-form-item>

          </el-row>
          <el-row :gutter="30" style="text-align: center;margin:30px 0; ">
            <el-button  v-if="btnRight.btnPhotoArchivalOpenVideo"  @click="openVideo()" >打开视频</el-button>
            <el-button  v-if="btnRight.btnPhotoArchivalCloseVideo" @click="closeVideo()">关闭视频</el-button>
            <el-button  v-if="btnRight.btnPhotoArchivalIdPhoto" @click="savePhotoData($event,0)">证件拍照</el-button>
            <el-button  v-if="btnRight.btnPhotoArchivalTransactorPhoto"  @click="savePhotoData($event,1)">办理人拍照</el-button>
            <el-button  v-if="btnRight.btnPhotoArchivalBothPhoto" @click="savePhotoData($event,2)">同时拍照</el-button>
          </el-row>
          <el-row>
            <!--拍照新设备拍照-->
           <!-- <div>

              <div style="float:left">

                <div id="video1">
                  <img id="video" style="width:600px;height:300px" >
                </div>

                <label >设备控制/参数设置</label>
                <div style="margin-left:5px;margin-top:10px;float:left">
                  <label >设备</label>
                  <select id="devicList" ></select>
                  <label >分辨率</label>
                  <select id="reslutionList" ></select>

                </div>


              </div>
              <div style="margin-left: 20px;">
                <el-button  v-if="btnRight.btnPhotoArchivalOpenVideo"  @click="savePhotoCert (1)" >证件拍照</el-button>
                <el-button  v-if="btnRight.btnPhotoArchivalOpenVideo"  @click="savePhotoCert (2)" >办理人拍照</el-button>
                <ul id="parentUl"></ul>
              </div>


            </div>-->
            <!--拍照end-->
          </el-row>
        </div>

      </el-form>
      <hr>
      <el-form :model="savePhoto" :inline="true"  :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
        <div class="PageItem">
          <el-row class="PageInfo"><i class="info-bar"></i>照片查看</el-row>
          <div style="padding:0 20px;">
            <div class="border1 photowrapper">
              <div>
                <el-radio-group  v-model="loadPhoto.documentTypeCode" v-if="loadPhoto.documentType.length>0">
                  <el-radio-button  label="0" @click="loadPhotoWidthType(0)"><span @click="loadPhotoWidthType(0)">全部</span></el-radio-button>
                  <el-radio-button  v-for="(item) in loadPhoto.documentType" :label=item.dataCode  :key="item.dataCode"><span @click="loadPhotoWidthType(item.dataCode)">{{item.dataName}}</span></el-radio-button>
                </el-radio-group>
              </div>
              <div class="imgcontent">
                <div class="block" v-for="(fit,key) in loadPhoto.Images" :key="key" style="position: relative;">
                 <el-image
                    style="width: 100%; height: 100%"
                    :src="fit.thumbPath"
                    fit="fill"
                    :preview-src-list="[fit.thumbPath]"></el-image> <i v-show="fit.thumbPath!=null"  @click="deleteImage(fit.id,fit.version)"  class="item-icon el-icon-circle-close"></i>
                </div>

              </div>
            </div>
          </div>
        </div>
      </el-form>
    </div>
  </div>
</template>
<script>
  import axios from "axios"
  import store from '@/store'
  import { getToken } from '@/utils/auth'
  import * as Type from '@/api/service'
  import { sendInitMsg ,unload,Buzzer,Capture,continuCapture,CaptureBase64Ex,addlist,ShowDevSettingWindow,AutoFoucs,ShowImageSettingWindow}    from '@/api/mainH5'
  import  { StartWebSocket,sendWsMessage,photoType,setPhotoType }   from '@/api/WebSocket'
  import  {getSingleCamera}    from '@/api/singleCamera'
  import GPY_S620A3XR from '@/api/GPY_S620A3XR'


  export default {
    name: "PhotoArchival",
    data() {
      return {
        loading:false,
        dictionary: {},   //字典
        saveurl:  "/api/photo-archival/save-photo-archival",
        savePhoto: {
          businessCode: this.businessCode,
          documentTypeCode: "", //文档类型
          certificatesImageFile: "",//证件照片文件
          peopleImageFile: ""   //办理人照片文件
        },
        loadPhoto: {            //加载图片
          documentTypeCode: 0,
          documentType: [
            // {dataName:"测试",dataCode:"1"}
          ],     //文档根据字典加载
          Images: []   //根据字典编码加载图片信息
        },
        device: {
          mainDevice: [],
          mainDeviceSelected: null,
          mainDeviceResolutions: [],
          mainDeviceResolutionSelected: null,
          assistDevice: [],
          assistDeviceSelected: null,
          assistDeviceResolutions: [],
          assistDeviceResolutionSelected: null,
        },
        moreFlag:false,    //折叠
        ruleForm: {
          "funeralDead": {
            "id": 0,
            "businessCode": "",
            "deadName": "",
            "certificateNo": "",
            "deadGender": "",
            "benefitDistrict": "",
            "exemptionType": "",
            "transportPlace": "",
            "version": 0
          },
          "familyMember": {
            "id": 0,
            "memberName": "",
            "memberGenderCode": "",
            "memberGender": "",
            "mobilePhone": "",
            "otherPhone": "",
            "address": "",
            "certificateTypeCode": "",
            "certificateNo": "",
            "memberRelation": "",
            "version": 0
          },
          "familyAgent": {
            "id": 0,
            "agentType": "",
            "agentUnitName": "",
            "agentName": "",
            "mobilePhone": "",
            "otherPhone": "",
            "certificateNo": "",
            "agentRelation": "",
            "version": 0
          },
          "dicts": {
            "cremation_certificate_printing_operation_type": {
              "dataCode": 0,
              "dataText": "",
              "dataTextAbbr": "",
              "disableState": 0,
              "asDefault": 0
            }
          },
          "documentFile": [
            {
              "id": 0,
              "documentTypeCode": 0,
              "filePath": "",
              "thumbPath": ""
            }
          ],//定义对象
          'SingleCamera':{

          }
        },
        rules: {
          name: [
            {required: true, message: '请输入活动名称', trigger: 'blur'},
            {min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur'}
          ],
        },
        businessCode: "",
        //按钮权限
        btnRight: {
          btnPhotoArchivalCodeScanning: true,  //业务编码扫码
          btnPhotoArchivalOpenVideo: true,    //打开视频
          btnPhotoArchivalCloseVideo: true,  //关闭视频
          btnPhotoArchivalIdPhoto: true,   //证件拍照
          btnPhotoArchivalTransactorPhoto: true,   // 办理人拍照
          btnPhotoArchivalBothPhoto: true,   //同时拍照
        },devPhList:[{
          "text":"S620A3X",
          "value":"S620A3X"
        },{
          "text":"USB CAM2",
         "value":"USB CAM2"
        }
        ],selectDev:"",//选择的设备
         timer:0,//定时器
         base64StringVue:"",
         quickRun:[{
                  "text":"不旋转",
                  "value":"不旋转"
                  },{
                  "text":"90",
                  "value":"90"
                   },{
                  "text":"180",
                   "value":"180"
                   },{
                   "text":"270",
                   "value":"270"
                    }
         ]

      }
    },
    mounted() {
      //在钩子函数中可以使用js
      //按钮权限
       this.btnRight = this.$route.meta.buttons;
       //遍历属性赋值将true与false字符串转换成布尔型的值
        for (let key of Object.keys(this.btnRight)) {
          this.btnRight[key]=(this.btnRight[key]|| this.btnRight[key]=="true")?true:false;
        }
      this.$store.dispatch('user/getdictionary').then((res) => {     //获取字典数据
        this.dictionary = res;
        this.$set(this.dictionary, res)
        // console.log(this.dictionary)
      }).catch(()=>console.log('promise catch err'));

      this.businessCode = this.$store.getters.businessCode
      if (this.businessCode) {
        this.searchData(this.businessCode)
      }
      // alert(document.getElementById("view1"))
      // 初始化高拍仪设备、

      //定义对象
      //初始化并配置UI
      let ws = "";
      //模式
      var g_obj =  "";
     //图片保存的目录
      let g_savePicDir = "c:/tmp/";
      let SingleCamera=getSingleCamera();
      //初始化定义的对象
      SingleCamera.InitSDKAndInitUI(g_obj);
      this.SingleCamera=SingleCamera;
      GPY_S620A3XR.camera.load();
      let subTypes = GPY_S620A3XR.camera.subTypes();
      this.device.mainDevice = (subTypes.length > 0 ? subTypes[0] : []);
      this.device.mainDeviceSelected=this.device.mainDevice[0].value;
      this.device.mainDeviceResolutions=this.device.mainDevice[0].resolutions;
      this.device.mainDeviceResolutionSelected=this.device.mainDeviceResolutions[0].value;
      this.device.assistDevice = (subTypes.length > 1 ? subTypes[1] : []);
      this.device.assistDeviceSelected=this.device.assistDevice[0].value;
      this.device.assistDeviceResolutions=this.device.assistDevice[0].resolutions;
      this.device.assistDeviceResolutionSelected=this.device.assistDeviceResolutions[0].value;
    },
    beforeDestroy() {
      GPY_S620A3XR.camera.unload();
      //测试end'
      var g_obj =  "";
      this.SingleCamera.UInitCamera(g_obj);
    },
    created() {

    },
    methods: {
      //数据读取
      ReadData() {
        this.loading = true;
        let postData = {
          "businessCode": this.businessCode,
          "dictTypeCodes": []
        }
        Type['loadphotoarchivalall'](postData).then(response => {

          const {data} = response;
          if (!data) {
            this.loading = false;
            this.$message('数据读取失败')
            return
          }
          this.ruleForm = data;
          //根据字典取文档类型
          let typename = []
          if (this.ruleForm.documentFile.length > 0) {
            this.loadPhoto.Images = this.ruleForm.documentFile     //加载所有返回全部类型的图片
            this.ruleForm.documentFile.forEach(item => {
              if (typename.indexOf(item.documentTypeCode) < 0) {
                typename.push(item.documentTypeCode)
              }
            })
            typename.forEach(code => {
              this.dictionary.document_type.forEach(n => {

                if (code == n.dataCode) {                 //遍历循环出所有的文档类型
                  let obj = {}
                  obj.dataName = n.dataText
                  obj.dataCode = n.dataCode
                  if( this.loadPhoto.documentType.length>0){
                    var flag=false;
                    for(var i=0;i< this.loadPhoto.documentType.length;i++){
                       var item=this.loadPhoto.documentType[i];
                         if(obj.dataCode==item.dataCode){
                           flag=true;
                         }
                    }
                    if(!flag){
                      this.loadPhoto.documentType.push(obj);
                    }
                  }else{
                    this.loadPhoto.documentType.push(obj);
                  }

                }
              })
            })
          }
          //   //数据读取成功

          this.loading = false;
        }).catch(error => {
          this.$message(error)
          this.businessCode = ""
          this.loading = false;
        })
      },
      //输入业务编码回车查询
      searchData() {
        if (!this.businessCode) {
          this.$message("请输入业务编码");
          return
        }
        this.$store.dispatch('user/setbusinessCode',this.businessCode).catch(()=>console.log('promise catch err'));
        this.ReadData();
      },//删除图片方法
       deleteImage(idVal,versionVal){
         let this_delete=this;
         this_delete.$confirm('删除图片, 是否继续?', '提示', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
           type: 'warning'
         }).then(() => {
           let postData = {
             id:idVal,
             version:versionVal
           }
           //后台删除接口
           Type['deletePhotoArchivalWithId'](postData).then(response => {
             let result = response;
             const {data} = result
             if (!data) {
               this_delete.$message('图片删除失败.')
             }
             //重新查询
             this_delete.ReadData();
           }).catch(error => {
             this_delete.$message(error)
           })
         }).catch(() => {
           //几点取消的提示
         });
      },
      loadPhotoWidthType(code) {
        this.loadPhoto.Images = []
        if (code == 0) {  //全部
          this.loadPhoto.Images = this.ruleForm.documentFile
        }
        this.ruleForm.documentFile.forEach(item => {
          if (item.documentTypeCode == code) {
            this.loadPhoto.Images.push(item)
          }
        })

      },//新式保存图片数据
      savePhotoData(e, data) {
        let this_local=this;
        if(! this_local.businessCode || ! this_local.savePhoto.documentTypeCode){
          this_local.$message('业务编码或照片类型不能为空');
          return ;
        }
        // 证件拍照，返回客户端本地照片地址
        let imgbase64_1=null;
        // 办理人拍照，返回客户端本地照片地址
        let imgbase64_2=null;

        if(data==0){
          imgbase64_1=GPY_S620A3XR.camera.createImageBase64(1);
        }else if(data==1){
          // 办理人拍照，返回客户端本地照片地址
          imgbase64_2=GPY_S620A3XR.camera.createImageBase64(2);
        }else if(data=2){
          imgbase64_1=GPY_S620A3XR.camera.createImageBase64(1);
          // 办理人拍照，返回客户端本地照片地址
          imgbase64_2=GPY_S620A3XR.camera.createImageBase64(2);
        }else{
          return ;
        }

        // 后续进行本地照片上传即可
        // console.log(imgbase64_1)
        // console.log(imgbase64_2);
        //数据
        let postdata={
          "businessCode":this_local.businessCode,
          "documentTypeCode":this_local.savePhoto.documentTypeCode
        };
        let formData={
          "data":postdata,
          "certificatesImageFile":imgbase64_1,
          "peopleImageFile": imgbase64_2

        };
        //文件上传,传输地址加上api，路径修改为全路径，因此前面要加/api
        axios({
          method: "post",
          // baseURL: "api",
          baseURL: ROOT,
          withCredentials: true,
          timeout: 5000 ,
          url: "/api/photo-archival/save-photo-archival",
          headers: {
            "Content-Type": "application/json",
            token:store.getters.token?getToken():null
          },
          data: formData
        })
          .then(res => {

            const {data} = res;
            if(data && data.code==1){
              this_local.searchData(this_local.businessCode);
            }
            else if ( data && data.message) {
              this_local.$message(data.message)
              return
            }
          }).catch(error => {
          this_local.$message(error)
        });
        //

      },
      //身份证拍照
       savePhotoCert(type){
         setPhotoType(type);
        //调用拍照函数
          this.CaptureBase64Vue()
         let this_local=this;
         if(! this_local.businessCode || ! this_local.savePhoto.documentTypeCode){
           this_local.$message('业务编码或照片类型不能为空');
           return ;
         }
         var t1 = window.setTimeout(function(){

         },1000);
        /* setBusinessCode(this_local.businessCode);
         setDocumentTypeCode( this_local.savePhoto.documentTypeCode);*/
         // 证件拍照，返回客户端本地照片地址
         let imgbase64_1=null;
         // 办理人拍照，返回客户端本地照片地址
         let imgbase64_2=null;
         if(type==1){
           imgbase64_1=base64String
           if(imgbase64_1==null && imgbase64_1==""){
             return ;
           }
         }else if(type==2){
           imgbase64_2=base64String
           if(imgbase64_2==null && imgbase64_2==""){
             return ;
           }
         }else{
           return ;
         }
           //数据
           let postdata={
             "businessCode":this_local.businessCode,
             "documentTypeCode":this_local.savePhoto.documentTypeCode
           };
           let formData={
             "data":postdata,
             "certificatesImageFile":imgbase64_1,
             "peopleImageFile": imgbase64_2

           };
           //文件上传
           axios({
             method: "post",
             baseURL: "api",
             withCredentials: true,
             timeout: 5000 ,
             url: "/photo-archival/save-photo-archival",
             headers: {
               "Content-Type": "application/json",
               token:store.getters.token?getToken():null
             },
             data: formData
           })
             .then(res => {

               const {data} = res;
               if(data && data.code==1){
                 this_local.searchData(this_local.businessCode);
               }
               else if ( data && data.message) {
                 this_local.$message(data.message)
                 return
               }
             }).catch(error => {
             this_local.$message(error)
           });

       },
      openVideo() {
        GPY_S620A3XR.camera.openVideo();
      },
      closeVideo() {
        GPY_S620A3XR.camera.closeVideo();
      },
      mainDeviceChange(val) {
        this.device.mainDeviceResolutions =[];
        for (let i = 0; i < this.device.mainDevice.length; i++) {
          if (this.device.mainDevice[i].value == val) {
            this.device.mainDeviceResolutions = this.device.mainDevice[i].resolutions;
            this.device.mainDeviceResolutionSelected=this.device.mainDeviceResolutions[0].value;
            this.changeSubType(1);
            break;
          }
        }
      },
      assistDeviceChange(val) {
        this.device.assistDeviceResolutions=[];
        for (let i = 0; i < this.device.assistDevice.length; i++) {
          if (this.device.assistDevice[i].value == val) {
            this.device.assistDeviceResolutions = this.device.assistDevice[i].resolutions;
            this.device.assistDeviceResolutionSelected=this.device.assistDeviceResolutions[0].value;
            this.changeSubType(2);
            break;
          }
        }
      },
      changeSubType(deviceIndex)
      {
        if(deviceIndex==1)
        {
          GPY_S620A3XR.camera.changeSubType(deviceIndex,this.device.mainDeviceResolutionSelected,this.device.mainDeviceSelected);
        }
        else
        {
          GPY_S620A3XR.camera.changeSubType(deviceIndex,this.device.assistDeviceResolutionSelected,this.device.assistDeviceSelected);
        }

      },//拍照
      capturePhoto(){
        var time = new Date();
        var checktime = time.getHours();
        var filepath = document.getElementById("saveText").value  + time.getYear() + time.getMonth ()+ time.getDate() + time.getDate ()+ time.getTime()+"." + document.getElementById("imageType").value;
        var jsonObj = {FuncName:'camCaptureImageFile',argument:{filePath:filepath}};
        sendWsMessage(jsonObj);
        //showImageFile(filepath);
        //if (t1 == 0) {
        this.timer = setTimeout(function(){addlist("parentUl",filepath);},2000);
      },//base64拍照
       CaptureBase64Vue(){
         var jsonObj = {FuncName:'CaptureEncodeBase64'};
         sendWsMessage(jsonObj);
      },//设置旋转
       SetRotationStyleMethod(){
        //设置旋转
        SetRotationStyle();
      }
    }, watch: {
      /*返回字符串*/
      'sockets.base64String'() {
          alert(sockets.base64String);
      }
    }, computed: {
      //计算
      getBase64String () {
           return ''
      },
    },
  }
</script>

<style scoped>
  .border1{
    border:1px solid #e2dada;
    padding:10px;
  }
  .edit-cell{
    padding: 3px ;
  }
  .el-form-item {
    margin-bottom: 5px !important;
  }
  .marginright50{
    margin-right: 50px;
  }
  .video{
    display: inline-block;
    display: flex;
    padding:50px;
    justify-content: space-around;
  }
  .video .content{
    border:1px solid #e2e2e2;
  }
  .photowrapper{
    width:1400px;
    padding:20px;
  }
  .imgcontent{
    padding:30px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .imgcontent .block{
    width:300px;
    height: 200px;
    margin-bottom: 20px;
  }
  .item-icon{
    position: absolute;
    right: 0;
    top: 0;
    color:red;
  }
</style>
